using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

using System.Timers;
using BAL;

namespace Website
{
    public class Global : System.Web.HttpApplication
    {
        static System.Timers.Timer Clock;
        public static bool IsFirstTime = false;
        public static bool EnableRemoveCached = Convert.ToBoolean(ConfigurationManager.AppSettings["EnableRemoveCached"]);
        public static DateTime LastestRun = DateTime.MinValue;
        public static int iChangeID_NewsPublished = 0;
        public static int iCount = 0;

        protected void Application_Start(object sender, EventArgs e)
        {
        }

        protected void Application_End(object sender, EventArgs e)
        {

        }

        protected void Application_Error(Object sender, EventArgs e)
        {
            Exception ex = Server.GetLastError().GetBaseException();
            string WriteErrorToFile = ConfigurationManager.AppSettings["WriteErrorToFile"];
            if (WriteErrorToFile != null && WriteErrorToFile.ToUpper() == "TRUE")
            {
                Utils.CreateLogFiles Err = new Utils.CreateLogFiles();
                Err.ErrorLog(Server.MapPath("/ErrorLog"), Environment.NewLine + Environment.NewLine + Request.RawUrl.ToString() + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace);
            }
            if (HttpContext.Current.Request.Path.ToLower() != "/default.aspx"
                && HttpContext.Current.Request.Path.ToLower() != "/home.htm"
                && HttpContext.Current.Request.Path.ToLower() != "/home.aspx") Response.Redirect("/home.htm");
            else Response.Redirect("/error.html");
        }
    }
}